package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.mapper.LogMapper;
import com.itheima.pojo.Logging;
import com.itheima.pojo.PageBody;
import com.itheima.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl implements LogService {
    @Autowired
    private LogMapper loggerMapper;

    @Override
    public PageBody findByPage(Integer page, Integer pageSize) {
        PageHelper.startPage(page,pageSize);
        List<Logging> list = loggerMapper.findAll();
        PageInfo<Logging> logInfo = new PageInfo<>(list);
        return new PageBody(logInfo.getTotal(),logInfo.getList().toArray());
    }

    @Override
    public void saveLog(Logging logging) {
        loggerMapper.saveLog(logging);
    }
}
